/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package evaluation;

import util.Pair;

/**
 *
 * @author phong
 */
public class Edge {
    String label;
    Vertex v1, v2;
    
    public Edge(String label, Vertex v1, Vertex v2) {
        this.label = label;
        this.v1 = v1;
        this.v2 = v2;
    }
    
    public String getLabel() {
        return this.label;
    }
    
    public Pair<Vertex,Vertex> getVerices() {
        return new Pair<Vertex,Vertex>(v1, v2);
    }
    
    public Vertex getFirstVertex() {
        return this.v1;
    }
    
    public Vertex getSecondVertex() {
        return this.v2;
    }
    @Override
    public boolean equals(Object other) {
        if (other instanceof Edge) {
            Edge that = (Edge)other;
            return that.label.equals(this.label) && that.v1.equals(this.v1) && that.v2.equals(this.v2);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return this.label.hashCode() * 31 + this.v1.hashCode() * 17 + this.v2.hashCode();
    }
    
    @Override
    public String toString() {
        return "(" + this.v1.toString() + " --" + this.label + "--> " + this.v2.toString() + ")";
    }
}